<template>
  <div>
  <header>
    <div class="return" @click="toHome" v-show="isShow">
      <span class="iconfont iconzuojiantou"></span>
    </div>
    <div class="header" v-show="!isShow" :style="{'opacity':opt}">
      <div class="header-return" @click="toHome">
        <span class="iconfont iconzuojiantou"></span>
      </div>
      <div class="city-title">
        城市选择
      </div>
    </div>
  </header>

  </div>
</template>

<script>
export default {
  data () {
    return {
      isShow: true,
      opt: 0
    }
  },
  methods: {
    toHome () {
      this.$router.push('/')
    }
  },
  mounted() {
    window.addEventListener('scroll',()=> {
      let top = document.documentElement.scrollTop
      let tempOpt = top / 1000
      tempOpt = tempOpt > 1 ? 1 : tempOpt

      if (top > 45){
        this.isShow = false
        this.opt = tempOpt
      }else{
        this.isShow = true
      }
    })
  }
}
</script>

<style scoped lang="stylus">
@import "~css/common.styl"
.return
  position: absolute
  top: .1rem
  left: .1rem
  width: .72rem
  height:.72rem
  line-height: .72rem
  display: block
  border-radius: 50%
  background-color: rgba(0,0,0,.5)
  z-index: -1
  color: #fff
  font-size: .36rem
  text-align: center
.header
  width: 100%
  line-height: .88rem
  background-color: $bgColor
  font-size: .28rem
  color: #fff
  position: fixed
  .header-return
    padding: 0 .2rem
    width: .2rem
    text-align: center
    font-weight: bold
    position: absolute
  .city-title
    text-align: center
    font-size: .32rem
</style>
